package com.tarena.lbs.attach.api.impl;

import com.tarena.lbs.attach.api.dto.AttachBindDTO;
import com.tarena.lbs.attach.api.dto.AttachDeleteDTO;
import com.tarena.lbs.attach.api.dto.QrCodeDTO;
import com.tarena.lbs.attach.api.service.AttachService;
import com.tarena.lbs.attach.service.FileService;
import com.tarena.lbs.attach.service.QrCodeService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class AttachServiceImpl implements AttachService {

    @Autowired
    private FileService fileService;

    @Autowired
    private QrCodeService qrCodeService;

    @Override
    public boolean bindImage(AttachBindDTO attachBindDTO) {
        return fileService.bindFileToEntity(attachBindDTO.getFileId(),
                attachBindDTO.getEntityType(),
                attachBindDTO.getEntityId());
    }

    @Override
    public boolean deleteImage(AttachDeleteDTO attachDeleteDTO) {
        return fileService.deleteFile(attachDeleteDTO.getFileId());
    }

    @Override
    public String generateQrCode(QrCodeDTO qrCodeDTO) {
        return qrCodeService.generateQrCode(qrCodeDTO.getContent(),
                qrCodeDTO.getWidth(),
                qrCodeDTO.getHeight());
    }
}